<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.15"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TTMath: ttmath::ThreadLock Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="ttmath_logo_for_doxygen_doc.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">TTMath
   &#160;<span id="projectnumber">0.9.4_prerelease_2019-07-31</span>
   </div>
   <div id="projectbrief">&nbsp;C++ bignum library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.15 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespacettmath.html">ttmath</a></li><li class="navelem"><a class="el" href="classttmath_1_1_thread_lock.html">ThreadLock</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a>  </div>
  <div class="headertitle">
<div class="title">ttmath::ThreadLock Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>objects of this class are used to synchronize  
 <a href="classttmath_1_1_thread_lock.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="ttmaththreads_8h_source.html">ttmaththreads.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:ac14a9e9971fa9b6aa397fa391f6fc09e"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classttmath_1_1_thread_lock.html#ac14a9e9971fa9b6aa397fa391f6fc09e">Lock</a> ()</td></tr>
<tr class="separator:ac14a9e9971fa9b6aa397fa391f6fc09e"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>objects of this class are used to synchronize </p>
<p>this is a simple skeleton of a program in multithreads environment: </p><pre class="fragment">#define TTMATH_MULTITHREADS
#include&lt;ttmath/ttmath.h&gt;

TTMATH_MULTITHREADS_HELPER

int main()
{
[...]
}
</pre><p>make sure that macro TTMATH_MULTITHREADS is defined and (somewhere in *.cpp file) use TTMATH_MULTITHREADS_HELPER macro (outside of any classes/functions/namespaces scope) </p>

<p class="definition">Definition at line <a class="el" href="ttmaththreads_8h_source.html#l00188">188</a> of file <a class="el" href="ttmaththreads_8h_source.html">ttmaththreads.h</a>.</p>
</div><h2 class="groupheader">Member Function Documentation</h2>
<a id="ac14a9e9971fa9b6aa397fa391f6fc09e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac14a9e9971fa9b6aa397fa391f6fc09e">&#9670;&nbsp;</a></span>Lock()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool ttmath::ThreadLock::Lock </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>lock the current thread</p>
<p>it uses a global mutex created by TTMATH_MULTITHREADS_HELPER macro </p>

<p class="definition">Definition at line <a class="el" href="ttmaththreads_8h_source.html#l00197">197</a> of file <a class="el" href="ttmaththreads_8h_source.html">ttmaththreads.h</a>.</p>
<div class="fragment"><div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;        {</div><div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;            <span class="keywordflow">if</span>( pthread_mutex_lock(&amp;<a class="code" href="namespacettmath.html#af7ec4eb78a37bd53d8a6ec921be57288">ttmath_mutex</a>) != 0 )</div><div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;                <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;</div><div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;        <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;        }</div><div class="ttc" id="namespacettmath_html_af7ec4eb78a37bd53d8a6ec921be57288"><div class="ttname"><a href="namespacettmath.html#af7ec4eb78a37bd53d8a6ec921be57288">ttmath::ttmath_mutex</a></div><div class="ttdeci">pthread_mutex_t ttmath_mutex</div></div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="namespacettmath.html#af7ec4eb78a37bd53d8a6ec921be57288">ttmath::ttmath_mutex</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="ttmaththreads_8h_source.html">ttmaththreads.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.15
</small></address>
</body>
</html>
